package com.codejoys.web;

import com.codejoys.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

//@Controller
//public class UserController {
//    @Autowired
//    @Qualifier("userServiceImpl")
//    private UserService service;
//
//    public void findAll(){
//        service.findAll();
//    }
//}

//非单例模式
@Controller
//@Scope("singleton")   //singleton:单例  默认
@Scope("prototype")     //prototype:原型
public class UserController {
    public UserController() {
        System.out.println("UserController被创建。。。");
        //在第一次取得时候才会被创建
    }

    @Autowired
    @Qualifier("userServiceImpl")
    private UserService service;

    public void findAll() {
        service.findAll();
    }
}
